# -*- coding: utf-8 -*-
'''
Created on 2010-03-21

@author: Jarek
'''

class ChangeInfo(object): #pylint: disable-msg=R0902,R0903
    '''
    Stores information about repository change. It might be taken from
    Mercurial or Subversion or any other...

    It has: 
        id: unique id of the change
        rev: revision number for the change
        user: user name who made the change
        email: email of the user who made the change
        date: date of the change in datetime format
        files: space-separated list of files changed in the change
        comment: description given by the user for the change
        link: link under which the change is visible
    '''


    def __init__(self, change_id, rev, user, email, #pylint: disable-msg=R0913
                  date, files, comment, link): 
        '''
        Creates the change object.
        '''
        self.change_id = change_id
        self.rev = rev
        self.user = user
        self.email = email
        self.date = date
        self.files = files
        self.comment = comment
        self.link = link
    def get_date(self):
        """
        Retrieves date of the change. Used for sorting.
        """
        return self.date

    def __str__(self):
        return "Id: '%s', Rev: '%s', User: '%s', Email '%s', \
                Date: '%s', Files: '%s', Comment: '%s', Link: '%s'" % \
                (self.change_id, self.rev, self.user, self.email, \
                    self.date, self.files, self.comment, self.link)

    def __repr__(self):
        return "<changeinfo %s>" % str(self)

    def __cmp__(self, other):
        return cmp(self.change_id, other.change_id)

    def __hash__(self):
        return hash(self.change_id)
